export function getUrlParams(param) {
	let url = window.location.search;
	let theRequest = new Object();
	if (url.indexOf("?") != -1) {
		let str = url.substr(1);
		let strs = str.split("&");
		for (let i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
		}
	}
	console.log(theRequest[param])
	// console.log(111,param)
	// console.log(222,theRequest[param])
	return theRequest[param]
}
// import {
// 		getUrlParams
// 	} from '@/util/common/common.js'
// 	const channelNo = ref(getUrlParams('channelNo'))
const RegPhone = /^((1[0-9]))\d{9}$/;
export function getHashSearchParam(key) {
	const url = location.href
	// 获取 hash 值，不包含 '#' 号
	const hash = url.substring(url.indexOf("#") + 1)
	// 查找 '?' 号所在的索引
	const searchIndex = hash.indexOf("?")
	// '?' 号后面接的是索引参数，如果找到则+1，去除'?' 号
	const search = searchIndex !== -1 ? hash.substring(searchIndex + 1) : ""
	// 把搜索参数字符串提过URLSearchParams转成对象形式
	const usp = new URLSearchParams(search)
	// 通过URLSearchParams自带的get方法，查询键所对应的值
	return usp.get(key)
}
//统计事件
const addClick = function addClick(key, key2 = "") {
	let channel_no = uni.getStorageSync('channelNo')
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'https://data-api.ksbmtb.com:8882/api/app/event/add', //仅为示例，并非真实接口地址。
			method: "POST",
			data: {
				event_name: key,
				project_name: 'map_xcx',
				event_value: key2,
				// channel_no: "VXHead_CS"
				channel_no
			},
			header: {
				'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
			},
			success: async (res) => {
				resolve(res.result)
			}
		});
	});
}
export {
	RegPhone,
	addClick

}
